package dao

import "zg3yk/global"

func Find[T any](id uint, data *T) bool {

	err := global.DB.Where("id = ?", id).Find(&data)
	if err != nil {
		return false
	}
	return true
}
func Create[T any](where *T, data *T) bool {

	err := global.DB.Where(where).Create(&data)
	if err != nil {
		return false
	}
	return true
}
func FindWhere[T any](Where *T, data *T) bool {

	err := global.DB.Where(Where).Find(&data)
	if err != nil {
		return false
	}
	return true
}
func FindList[T any](Where *T, data *[]T) bool {

	err := global.DB.Where(Where).Find(&data)
	if err != nil {
		return false
	}
	return true
}
func FindSearch[T any](videoname string, data *T) bool {

	err := global.DB.Where("videoname like ?", "%"+videoname+"%").Find(&data)
	if err != nil {
		return false
	}
	return true
}
